import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from "../views/Login";
import DashBoard from "../views/dashboard/DashBoard";
//import My from "../components/My";
Vue.use(VueRouter)

export const ordinaryRoutes = [
    {
        path: '/Login',
        name: 'Login',
        component: Login,
    },
  // {
  //   path: '/My',
  //   name: 'My',
  //   component: My,
  // },
  {
    path:'/',
    name:'DashBoard',
    component:DashBoard,
    children:[
      {
        path:'/404',
        name:'404',
        component:() =>import('../components/404'),
        meta:{
          title:'404',
          icon:'md-close',
        }
      },
    ]
  },
]

export const asyncRoutes = [
  {
    path:'/DashBoard',
    name:'DashBoard',
    component:DashBoard,
    children:[
      {
        path:'/405',
        name:'405',
        component:() =>import('../components/405'),
        meta:{
          title:'405',
          icon:'md-close',
        }
      },
    ]
  },
]

// const router = new VueRouter({
//   mode: 'history',
//   base: process.env.BASE_URL,
//   ordinaryRoutes,
//   asyncRoutes
// })
const createRouter = () => new VueRouter({
  scrollBehavior: () => ({y:0}),
  routes:ordinaryRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}
export default router
